//gulp config

const gulp = require('gulp');
const imagemin = require('gulp-imagemin'); //压缩图片
const autoprefixer = require('gulp-autoprefixer') //加前缀
const sass = require('gulp-ruby-sass') //编译
const uglifycss = require('gulp-uglifycss') //压缩css
const sourcemaps = require('gulp-sourcemaps')
const concat = require('gulp-concat')

gulp.task('sass', () =>
	sass('src/scss/reportshare.scss', {
		//sourcemap: true
	})
	.on('error', sass.logError)
//	.pipe(sourcemaps.write('../../maps', {
//		includeContent: false,
//		sourceRoot: 'source'
//	}))
	//.pipe(gulp.dest('dist/css'))
	.pipe(autoprefixer({
		browsers: ['last 3 versions', 'safari 5', 'opera 12.1', 'ios 5', 'ios 6', 'android 4', 'ie 8', 'ie 9', 'Firefox >= 20'],
		cascade: false
	}))
	.pipe(gulp.dest('dist/css'))
)

gulp.task('style', () =>
	gulp.src('dist/css/index.css')
	.pipe(autoprefixer({
		browsers: ['last 3 versions', 'safari 5', 'opera 12.1', 'ios 5', 'ios 6', 'android 4', 'ie 8', 'ie 9', 'Firefox >= 20'],
		cascade: false
	}))
	.pipe(uglifycss({
		"maxLineLen": 10000,
		"uglyComments": true
	}))
	.pipe(concat('index.min.css'))
	.pipe(gulp.dest('dist/css'))
)

gulp.task('scripts',function(){
	return gulp.src('src/js/**/*.js')
		//.pipe(concat('bootstrap.js'))
		.pipe(gulp.dest('dist/js'));
})

/*gulp.task('styles', function() {
	return gulp.src('dist/css/publicity.css')
		.pipe(autoprefixer({
			browsers: ['last 2 versions', 'safari 5', 'opera 12.1', 'ios 5', 'ios 6','android 4'],
			cascade: false
		}))
		.pipe(gulp.dest('dist/css'))
});*/

gulp.task('default', ['sass','scripts']);